#include <bits/stdc++.h>
using namespace std;
const int maxa = 150000+100;
const int maxb = 40000+100;
int A[maxa], B[maxb];
int n, m;
bool cmp(int pa){
    int lb = 0, rb = m-1;
    int la = pa, ra = pa+m-1;
    bool left = true;
    while(la != ra){
        if(left){
            left = !left;
            if(A[la++] > B[lb++]) continue;
            else return false;

        }else{
            left = !left;
            if(A[ra--] > B[rb--]) continue;
            else return false;
        }
    }
    return true;
}
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> B[i];
    }
    int ans = 0;
    for (int p = 0; p < n-m+1; ++p) {
        if(cmp(p)) ++ans;
    }
    cout << ans;
    return 0;
}